﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VietTrips.Domain.Models;

namespace VietTrips.Domain.Contexts
{
    class ActivityContexts : DbContext
    {
        public ActivityContexts() 
            : base("DefaultConnection")
        {
            
        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<ActivityType>().HasMany<Activity>(s => s.Activities).WithMany(c => c.ActivityTypes).Map(c =>
            {
                c.MapLeftKey("ActivityTypeId");
                c.MapRightKey("ActivityId");
                c.ToTable("ActivityType_Relationships");
            });
            base.OnModelCreating(modelBuilder);
        }

        public DbSet<ActivityDetail> ActivityDetails { get; set; }
        public DbSet<Activity> Activities { get; set; }
        public DbSet<ActivityType> ActivityTypes { get; set; }
    }
}
